<template>
  <swiper class="swiper" :options="swiperOption">
    <!-- 每一屏 -->
    <swiper-slide><h1 class="item">第1屏</h1></swiper-slide>
    <swiper-slide><h1 class="item">第2屏</h1></swiper-slide>
    <swiper-slide><h1 class="item">第3屏</h1></swiper-slide>
    <swiper-slide><h1 class="item">第4屏</h1></swiper-slide>
    <!-- 底部小圆点 -->
    <div class="swiper-pagination" slot="pagination"></div>
    <!-- 上一张、下一张按钮 -->
    <div class="swiper-button-prev" slot="button-prev"></div>
    <div class="swiper-button-next" slot="button-next"></div>
  </swiper>
</template>

<script>
//引入组件
import { Swiper, SwiperSlide } from "vue-awesome-swiper";
//引入样式
import "swiper/css/swiper.css";

export default {
  name: "Test",
  components: {
    Swiper,
    SwiperSlide,
  },
  data() {
    return {
      swiperOption: {
        slidesPerView: 1,
        spaceBetween: 30,
        loop: true,
        autoplay: {
          delay: 2500, //轮播间隔
          disableOnInteraction: false, //鼠标点击后，是否禁止自动轮播
        },
        pagination: {
          el: ".swiper-pagination",
          clickable: true,
        },
        navigation: {
          nextEl: ".swiper-button-next",
          prevEl: ".swiper-button-prev",
        },
      },
    };
  },
};
</script>

<style lang="less" scoped>
.item {
  height: 300px;
  font-size: 40px;
  text-align: center;
  line-height: 300px;
  background-image: linear-gradient(45deg, red, yellow, green);
}
</style>
